package com.fulihui.systemcore.repository.impl;

import com.fulihui.systemcore.dal.convertor.ProjectConv;
import com.fulihui.systemcore.dal.mapper.ProjectMapper;
import com.fulihui.systemcore.dto.ProjectDTO;
import com.fulihui.systemcore.repository.ProjectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author leeson 2016年5月17日 下午2:57:36
 *
 */
@Repository
public class ProjectRepositoryImpl implements ProjectRepository {
    @Autowired
    private ProjectMapper projectMapper;

    @Override
    public ProjectDTO queryByCode(String projectCode) {
        return ProjectConv.convert2DTO(projectMapper.queryByCode(projectCode));
    }
    
    @Override
    public void insert(ProjectDTO record) {
        projectMapper.insert(ProjectConv.convert2DO(record));
    }

    @Override
    public void update(ProjectDTO record) {
        projectMapper.update(ProjectConv.convert2DO(record));
    }

    @Override
    public List<ProjectDTO> query(ProjectDTO record) {
        return ProjectConv.convert2List(projectMapper.query(ProjectConv.convert2DO(record)));
    }

    @Override
    public List<ProjectDTO> queryPage(ProjectDTO record, int page, int rows) {
        return ProjectConv.convert2List(projectMapper.queryPage(ProjectConv.convert2DO(record), page, rows));
    }

    @Override
    public int queryPageCount(ProjectDTO record) {
        return projectMapper.queryPageCount(ProjectConv.convert2DO(record));
    }
}